/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pb138.xml.wrda.servise;

import cz.muni.fi.pb138.xml.wrda.core.WAR;

import java.io.File;
import java.util.List;

/**
 * Service methods for functionality of WAR objects repository
 * @author Mychal
 */
public interface WARService {

    /**
     * Saves WAR object to repository
     * @param war WAR object to save
     * @throws IllegalArgumentException
     */
    void save(WAR war) throws IllegalArgumentException;

    /**
     * Deletes WAR Object from repository
     * @param war WAR object to delete
     * @throws IllegalArgumentException
     */
    void delete(WAR war) throws IllegalArgumentException;

    /**
     * This method returns all WAR entries stored repository
     * @return List of all WAR entries from xml database, empty list if there are no entries stored in database
     */
    List<WAR> getAllEntries();

    /**
     * Creates file in file repository for WAR archives based on it's file name and time stamp of upload
     * @param fileName file name of WAR archive
     * @param timeStamp upload time in millisecond (version)
     * @return
     * @throws IllegalArgumentException
     */
    File createFile(String fileName, Long timeStamp) throws IllegalArgumentException;

    /**
     * Extracts web.xml from WAR archive and saves it to repository
     * @param f must be WAR archive file
     * @param timeStamp upload time/version of uploaded WAR archive
     * @throws IllegalArgumentException
     */
    void saveDbEntry(File f, Long timeStamp) throws IllegalArgumentException;

    /**
     * Returns List of names of WAR objects from repository
     * @return List of names of WAR objects from repository
     */
    List<String> getFileNames();

    /**
     * Returns all WAR objects that contains part of given filter class name
     * @param filterName part of name of filter class of wanted WAR objects
     * @return List of WAR Objects which contains part of given filter class, empty list if no objects found
     * @throws IllegalArgumentException
     */
    List<WAR> getByFilter(String filterName);

    /**
     * Returns all WAR objects that has at least part of given fileName parameter in their fileName
     * @param fileName fileName of wanted WAR objects
     * @return List of WAR Objects with given fileName, empty list if no objects found
     * @throws IllegalArgumentException
     */
    List<WAR> getByFileName(String fileName) throws IllegalArgumentException;

    /**
     * Returns all WAR objects that contains part of given listener class name
     * @param listenerName part of name of listener class of wanted WAR objects
     * @return List of WAR Objects which contains part of given listener class, empty list if no objects found
     * @throws IllegalArgumentException
     */
    List<WAR> getByListener(String listenerName);

    /**
     * Returns single WAR object with given parameters
     * @param fileName fileName of wanted WAR object
     * @param timeStamp timeStamp of wanted WAR object (version)
     * @return single WAR object based on parameters, null if no object found
     * @throws IllegalArgumentException
     */
    WAR getByFileNameAndTimeStamp(String fileName, Long timeStamp);
}
